/*
 * Copyright (c) 2007,2008 Will Drewry <redpig@dataspill.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#include <stdio.h>  /* for printf, fgets */
#include <stdlib.h>  /* for atoi */
#include <stdint.h> /* for uint32_t */
#include <safe_iop.h> /* for awesomeness */

int main(int argc, char **argv) {
  char buf[1024];
  uint32_t width = 0, height = 0, pixels = 0;
  printf("Please specify the width of the new image: ");
  width = strtoul(fgets(buf, 1023, stdin), NULL, 10);
  printf("Please specify the height of the new image: ");
  height = strtoul(fgets(buf, 1023, stdin), NULL, 10);
  if (safe_mulx(&pixels, sio_u32(width), sio_u32(height))) {
    printf("The resulting image will have %u pixels.\n", pixels);
    return 0;
  } else {
    printf("Image size specified exceeds maximum size!\n");
    return 1;
  }
}
